function TreeNode(val) {
    this.val = val
    this.left = null
    this.right = null
}

var isSymmetric = function(root) {
    if (root == null) return true
    let left = root.left
    let right = root.right

    function dfs(left, right) {
        if (left == null && right == null) return true
        else if (left == null || right == null) return false
        else if (left.val != right.val) return false
        else {
            return dfs(left.left, right.right) && dfs(left.right, right.left)
        }
    }

    return  dfs(left, right)

};

let root = new TreeNode(4)
root.left = new TreeNode(2)
root.right = new TreeNode(7)
root.left.left = new TreeNode(1)
root.left.right = new TreeNode(3)
root.right.left = new TreeNode(6)
root.right.right = new TreeNode(9)
console.log(mirrorTree(root))
